<template>
  <app-header></app-header>

  <!--充值-->
  <div class="user-pay-box clearfix">
    <div class="user-pay-left fl">
      <p class="user-pay-title1">我的账户</p>
      <div class="user-pay-list">
        <a href="javascript:;" class="user-pay-list-on">充值</a>
        <a href="javascript:;" target="_blank">我的信息</a>
        <a href="javascript:;" target="_blank">投资记录</a>
        <a href="javascript:;" target="_blank">收益记录</a>
      </div>
    </div>
    <div class="user-pay-right fl">
      <p class="user-pay-title2">第三方支付平台</p>
      <div class="user-pay-form">
        <img src="@/assets/image/kq.png" alt="">
        <form action="http://localhost:8000/ylb/pay/kuaiqian/input" method="post" id="money_submit" target="_blank">
          <p class="user-pay-form-ts">请输入金额</p>
          <input type="text" placeholder="元" name="money" v-model="inputMoney" @blur="checkMoney" class="number-money" >
          <div class="input-err">{{moneyErr}}</div>
          <input type="hidden" name="uid" v-model="uid" readonly>
          <input type="hidden" name="token" v-model="token" readonly>
          <input type="button" value="支付" @click="userPay" class="submit-btn">
        </form>
      </div>
      <div class="user-pay-sm">
        <h3>温馨提示</h3>
        <p>1.为了您的使用安全，充值操作建议不要使用公共电脑。</p>
        <p>2.银行卡充值限额，由各银行限制。</p>
        <p>3.平台禁止用卡套现、虚拟交易、洗钱等行为，一经发现并确认，将终止该账户的使用。</p>
        <p>4.如果充值中出现问题，请联系客服400-890-0000。</p>
      </div>
    </div>

  </div>





  <app-footer></app-footer>

</template>

<script>
import AppHeader from "@/components/AppHeader";
import AppFooter from "@/components/AppFooter";

export default {
  name: "UserRechargeView",
  components:{
    AppHeader,
    AppFooter,
  },
  data(){
    return{
      uid :0,
      token:'',
      inputMoney:0,
      moneyErr:'',

    }
  },
  mounted() {
    //获取uid和token
    let sessionCache=window.sessionStorage.getItem("ylb");
    if (sessionCache){
      let sessionCachObject=JSON.parse(sessionCache);
      this.uid=sessionCachObject.id;
      this.token=sessionCachObject.token;
    }else {
      alert("想要充值,请先登录.")
    }
  },
  methods:{
    checkMoney(){
      if (isNaN(this.inputMoney)){
        this.moneyErr='请输入有效的金额.';
      }else if (parseFloat(this.inputMoney) <99){
        this.moneyErr='充值金额不能小于99';
      }else {
        this.moneyErr='';
      }
    },

    //用户充值.
    userPay(){
      if (this.uid === '' || this.uid === undefined){
        alert("请先登录.");
        return;
      }

      this.checkMoney();
      if (this.moneyErr === ''){
        document.forms[0].submit();
      }

    }
  }
}
</script>

<style scoped>

</style>